<!DOCTYPE html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <title>详情</title>
    <meta name="description" content="">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui, user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/public/layermobile/css/layer.css">
    <link rel="stylesheet" href="/assets/doorctrl/css/style.css"/>
    <link rel="stylesheet" href="/assets/doorctrl/css/fonts.css"/>
</head>
<body>
<div class="wraper">

    <div class="header font-16 flex padding">
        <a href="javascript:history.back()" style="color:#fff;"><div class="iconfont icon-zuo font-24"></div></a>
        <span>详情</span><div></div>
    </div>

    <div class="scroll-box">
        <if condition="!empty($data)">
            <volist name="data" key="key" id="vo">
                <div class="box Student title margin-10">
                    <a href="javascript:void(0);" class="no-flex font-color">
                        <div>
                            <p>{BEESCRM:$key}.&nbsp;&nbsp;{BEESCRM:$vo['user_info']['real_name']}
                                <if condition="$vo['type'] eq '1'" >（晚归）
                                    <elseif condition="$vo['type'] eq '2'" />（{BEESCRM:$nobackLable}）
                                    <else />(正常)
                                </if>
                            </p>
                            <p class="margin-8 font-gray font-12">
                                <span>{BEESCRM:$vo['dept_name']}</span>
                                <span class="margin-l18">{BEESCRM:$vo['user_info']['mobile']}</span>
                            </p>
                            <div class="sign"></div>
                        </div>
                        <!--<div class="iconfont icon-zhankai"></div>-->
                    </a>
                    <div class="prove font-12 hide">
                        <volist name="vo['enter_log']" id="logs">
                            <p class="flex">
                                <span>{BEESCRM:$logs['enter_time']|date='m-d H:i:s', ###}</span>
                            <span >
                                <if condition="$logs['from'] eq 0">由系统确认
                                    <if condition="$logs['status'] eq 0">正常</if>
                                    <if condition="$logs['status'] eq 1">晚归</if>
                                    <if condition="$logs['status'] eq 2">{BEESCRM:$nobackLable}</if>
                                </if>
                                <if condition="$logs['from'] neq 0 and $logs['controller_id']">由{BEESCRM:$logs['controller_name']}确认
                                    <if condition="$logs['status'] eq 0">正常</if>
                                    <if condition="$logs['status'] eq 1">晚归</if>
                                    <if condition="$logs['status'] eq 2">未归</if>
                                </if>
                            </span>
                            </p>
                        </volist>

                        <!--刷卡记录-->
                        <if condition="!empty($vo['event_record'])">
                            <div style="border-top: 1px solid #e6e6e6; margin: 10px 0;"></div>
                            <volist name="vo['event_record']" id="record">
                                <p class="flex">
                                    <span>{BEESCRM:$record['event_time']|date='m-d H:i:s', ###}<!--（<if condition="$record['in_out'] == 1">进</if><if condition="$record['in_out'] == 2">出</if>）--></span>
                                    <span>{BEESCRM:$record['door_name']}<if condition="$record['in_out'] eq 1">(进)</if><if condition="$record['in_out'] eq 2">(出)</if></span>
                                </p>
                            </volist>
                        </if>
                        <!--<span>{BEESCRM:$vo['last_in_time']|date='Y-m-d H:i', ###}</span>
                        <span class="pull-right">由系统确认</span>-->
                    </div>
                </div>
            </volist>
        </if>
    </div>
    <div style="padding: 20px;text-align: center" class="hide js_no_more">
        <p class="font-12 font-gray">没有更多记录了</p>
    </div>
    <if condition="empty($data)">
        <div class="NO-post">
            <div class="font-gray no-data"><p>暂无数据</p></div>
        </div>
    </if>
</div>
<input type="hidden" id="doorctrlId" name="doorctrlId" value="{BEESCRM:$doorctrlId}" />
<script src="/assets/public/jquery-2.1.0.min.js"></script>
<script src="/assets/doorctrl/js/public.js"></script>
<script src="/assets/public/layermobile/layer.js"></script>
<script src="/assets/doorctrl/js/doorctrlStat/yesterdayList.js"></script>
<script src="/assets/base/repair/js/sweetalert/lib/sweet-alert.min.js"></script>

<script>
    $(function () {
        var height = $(window).height();
        $('.wraper').css('minHeight', height);
        var height1=$(".header").innerHeight();
        var height2=$(".tab").innerHeight();
        var height3=$(".scroll-box").innerHeight();
        $(".no-data").css("height",height-height1-height2-height3-20);
        $('.no-flex').nextAll(".prove").addClass("show");
    });
</script>
<script>
    $(document).ready(function () {
        var user_id = "{BEESCRM:$userId}";
        var type = "{BEESCRM:$type}";
        var page = 2;


        //滚动条加载
        $(window).scroll(function () {
         if ($(document).scrollTop()+$(window).height() >= $(document).height()) {
             if (type == 1) {
                 ajaxGetLateData(user_id);      // 晚归
             }
             else if (type == 2) {
                 ajaxGetNoBackData(user_id);    // 未归
             }
             else if (type == 3) {
                 //ajaxGetImportantData(user_id); // 重点
             }
             else {
                 return false;
             }
         }
         });

        //ajax获取数据

        // 晚归
        function ajaxGetLateData(user_id) {
            var _html = '';
            $.ajax({
                url : "/Doorctrl/DoorctrlStat/ajaxGetSearchDetail/doorctrlId/{BEESCRM:$doorctrlId}",
                type : "POST",
                data : {"type" : type,"page" : page,"user_id" : user_id},
                dataType : "JSON",
                beforeSend : function () {
                    $('.load').show();
                },
                success : function (res) {
                    $('.load').hide();
                    if(res.status == 'S'){
                        for(var i=0;i<res.data.length;i++){

                            //确认日志循环
                            var log_html = '';
                            var controller_name = '系统';
                            var type = '';
                            if(res.data[i].enter_log.length > 0){
                                for(var j=0;j<res.data[i].enter_log.length;j++){
                                    //判断是系统还是管理员
                                    if(res.data[i].enter_log[j].from > 0){
                                        controller_name = res.data[i].enter_log[j].contoller_name;
                                    }

                                    //判断状态
                                    if(res.data[i].enter_log[j].status == 1){
                                        type = '晚归';
                                    }else if(res.data[i].enter_log[j].status == 2){
                                        type = "{BEESCRM:$nobackLable}";
                                        if (res.data[i].type == 1) {
                                            type = '未归';
                                        }
                                    }else{
                                        type = '正常';
                                    }
                                    log_html += '<p class="flex"><span>'+ res.data[i].enter_log[j].new_enter_time +'</span>' +
                                    '<span >由'+ controller_name +'确认 '+type+'</span></p>';
                                }
                            }else{
                                log_html = '<span>'+ res.data[i].last_in_time +'</span>' +
                                '<span class="pull-right">由系统确认 晚归</span>';
                            }
                            var event_html = '';
                            if(res.data[i].event_record.length > 0){
                                var in_out = '';
                                if(res.data[i].event_record[0]['in_out'] == 1){
                                    in_out = '(进)';
                                }
                                if(res.data[i].event_record[0]['in_out'] == 2){
                                    in_out = '(出)';
                                }
                                event_html = '<div style="border-top: 1px solid #e6e6e6; margin: 10px 0;"></div>' +
                                '<p class="flex">' +
                                '<span>' + res.data[i].event_record[0]['new_event_time']+ '</span>' +
                                '<span >'+res.data[i].event_record[0]['door_name']+ in_out +'</span>' +
                                '</p>';
                            }

                            _html += '<div class="box Student title margin-10">' +
                            '<a href="javascript:;" class="flex font-color">' +
                            '<div>' +
                            '<p>'+ res.data[i].user_info.real_name+ '</p>' +
                            '<p class="margin-8 font-gray font-12"><span>' + res.data[i].dept_name + '</span> <span class="margin-l18">'+ (res.data[i].user_info.mobile ? res.data[i].user_info.mobile :'') + '</span>' +
                            '</p>' +
                            '</div>' +
                            '<div class="iconfont icon-zhankai"></div>' +
                            '</a>' +
                            '<div class="prove font-12 hide">' + log_html + event_html + '</div>' +
                            '</div>'
                        }
                        if(_html != ''){
                            $(".js_no_more").addClass('hide');
                            $(".scroll-box").append(_html);
                        }else{
                            $(".js_no_more").removeClass('hide');
                        }
                        page += 1;
                    }else{
                        $.alert('error',res.message);
                    }
                },
                error : function () {
                    $.alert('error','网络错误，请重试');
                }
            });
        }

        // 未归
        function ajaxGetNoBackData(user_id) {
            var _html = '';
            $.ajax({
                url : "/Doorctrl/DoorctrlStat/ajaxGetSearchDetail/doorctrlId/{BEESCRM:$doorctrlId}",
                type : "POST",
                data : {"type" : type,"page" : page, "user_id" : user_id},
                dataType : "JSON",
                beforeSend : function () {
                    $('.load').show();
                },
                success : function (res) {
                    $('.load').hide();
                    if(res.status == 'S'){
                        for(var i=0;i<res.data.length;i++){
                            //确认日志循环
                            var log_html = '';
                            var controller_name = '系统';
                            var type = '';
                            if(res.data[i].enter_log.length > 0){
                                for(var j=0;j<res.data[i].enter_log.length;j++){
                                    //判断是系统还是管理员
                                    if(res.data[i].enter_log[j].from > 0){
                                        controller_name = res.data[i].enter_log[j].contoller_name;
                                    }

                                    //判断状态
                                    if(res.data[i].enter_log[j].status == 1){
                                        type = '晚归';
                                    }else if(res.data[i].enter_log[j].status == 2){
                                        type = "{BEESCRM:$nobackLable}";
                                    }else{
                                        type = '正常';
                                    }
                                    log_html += '<p class="flex"><span>'+ res.data[i].enter_log[j].new_enter_time +'</span>' +
                                    '<span >由'+ controller_name +'确认'+type+'</span></p>';
                                }
                            }else{
                                log_html = '<span>'+ res.data[i].last_in_time +'</span>' +
                                '<span class="pull-right">由系统确认夜不归宿</span>';
                            }

                            var event_html = '';
                            if(res.data[i].event_record.length > 0){
                                var in_out = '';
                                if(res.data[i].event_record[0]['in_out'] == 1){
                                    in_out = '(进)';
                                }
                                if(res.data[i].event_record[0]['in_out'] == 2){
                                    in_out = '(出)';
                                }
                                event_html = '<div style="border-top: 1px solid #e6e6e6; margin: 10px 0;"></div>' +
                                '<p class="flex">' +
                                '<span>' + res.data[i].event_record[0]['new_event_time']+ '</span>' +
                                '<span >'+res.data[i].event_record[0]['door_name']+ in_out +'</span>' +
                                '</p>';
                            }


                            _html += '<div class="box Student title margin-10">' +
                            '<a href="javascript:;" class="flex font-color">' +
                            '<div>' +
                            '<p>'+ res.data[i].user_info.real_name+ '</p>' +
                            '<p class="margin-8 font-gray font-12"><span>' + res.data[i].dept_name + '</span> <span class="margin-l18">'+(res.data[i].user_info.mobile ? res.data[i].user_info.mobile :'') + '</span>' +
                            '</p>' +
                            '</div>' +
                            '<div class="iconfont icon-zhankai"></div>' +
                            '</a>' +
                            '<div class="prove font-12 hide">' + log_html + event_html + '</div>' +
                            '</div>'
                        }
                        if(_html != ''){
                            $(".js_no_more").addClass('hide');
//                            $(".scroll-box").html(_html);
                            $(".scroll-box").append(_html);
                        }else{
                            $(".js_no_more").removeClass('hide');
                        }
                        page += 1;
                    }else{
                        $.alert('error',res.message);
                    }
                },
                error : function () {
                    $.alert('error','网络错误，请重试');
                }
            });
        }

        // 重点
        function ajaxGetImportantData(user_id) {
            var _html = '';
            $.ajax({
                url : "/Doorctrl/DoorctrlStat/ajaxGetSearchDetail/doorctrlId/{BEESCRM:$doorctrlId}",
                type : "POST",
                data : {"type" : type,"page" : page,"user_id" : user_id},
                dataType : "JSON",
                beforeSend : function () {
                    $('.load').show();
                },
                success : function (res) {
                    $('.load').hide();
                    if(res.status == 'S'){
                        for(var i=0;i<res.data.length;i++){
                            _html += '<div class="box Student title margin-10">' +
                            '<a href="javascript:;" class="flex font-color">' +
                            '<div>' +
                            '<p>'+ res.data[i].user_info.real_name+ '</p>' +
                            '<p class="margin-8 font-gray font-12"><span>' + res.data[i].dept_name + '</span> <span class="margin-l18">'+(res.data[i].user_info.mobile ? res.data[i].user_info.mobile :'')+ '</span>' +
                            '</p>' +
                            '</div>' +
                            '<div class="iconfont icon-zhankai"></div>' +
                            '</a>' +
                            '<div class="prove font-12 hide">' +
                            '<span>'+ res.data[i].last_in_time +'</span>' +
                            '<span class="pull-right">最后一次入寝时间</span>' +
                            '</div>' +
                            '</div>'
                        }
                        if(_html != ''){
                            $(".js_no_more").addClass('hide');
                            $(".scroll-box").append(_html);
                        }else{
                            $(".js_no_more").removeClass('hide');
                        }
                        page += 1;
                    }else{
                        fm.alert(res.message);
                    }
                },
                error : function () {
                    fm.alert('网络错误，请重试');
                }
            });
        }



    });


</script>
</body>
</html>